package org.breathe.thread.pool.common.entity;

import lombok.Data;
import org.breathe.thread.pool.common.enums.NotifyTypeEnum;

import java.util.ArrayList;
import java.util.List;

/**
 * 通知类
 * @author: breathe
 * @createTime: 2025-04-09
 */
@Data
public class NotifyItem {
    /**
     * 所有平台名
     */
    private List<String> platforms;

    /**
     * 是否报警
     */
    private boolean enabled = true;

    /**
     * 报警类型
     */
    private String type;

    /**
     * 警报门槛
     */
    private int threshold;

    /**
     * 报警时间间隔,单位秒
     */
    private int interval = 120;

    /**
     * 默认报警
     */
    private static final List<NotifyItem> DEFAULT_NOTIFY_ITEMS;

    static {
        NotifyItem changeNotify = new NotifyItem();
        changeNotify.setType(NotifyTypeEnum.CHANGE.getValue());

        NotifyItem livenessNotify = new NotifyItem();
        livenessNotify.setType(NotifyTypeEnum.LIVENESS.getValue());
        livenessNotify.setThreshold(80);

        NotifyItem capacityNotify = new NotifyItem();
        capacityNotify.setThreshold(80);
        capacityNotify.setType(NotifyTypeEnum.CAPACITY.getValue());

        NotifyItem rejectNotify = new NotifyItem();
        rejectNotify.setType(NotifyTypeEnum.REJECT.getValue());
        rejectNotify.setThreshold(1);

        DEFAULT_NOTIFY_ITEMS = new ArrayList<>(NotifyTypeEnum.values().length);
        DEFAULT_NOTIFY_ITEMS.add(livenessNotify);
        DEFAULT_NOTIFY_ITEMS.add(changeNotify);
        DEFAULT_NOTIFY_ITEMS.add(capacityNotify);
        DEFAULT_NOTIFY_ITEMS.add(rejectNotify);
    }

    public static List<NotifyItem> getDefaultNotifyItems() {
        return DEFAULT_NOTIFY_ITEMS;
    }
}
